package com.zzq.controller;


import com.zzq.domain.entity.SmileClient;
import com.zzq.domain.entity.SmileClientDelivery;
import com.zzq.domain.search.CheckRecordSearchParamet;
import com.zzq.result.SmileResult;
import com.zzq.service.ClientCheckService;
import com.zzq.service.ClientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RequestMapping("/client")
@RestController
@Api(value = "客户端用户信息控制接口",tags = {"客户端用户信息控制接口"})
public class  ClientController {

    @Autowired
    ClientService clientWxLoginService;

    @Autowired
    ClientCheckService checkService;

    /**
     * 登陆
     * @param code
     * @return
     */
    @GetMapping("/login")
    @ApiOperation("登录接口")
    public SmileResult login(@RequestParam("code") String code, @RequestParam("phoneCode") String phoneCode){
        SmileResult result = clientWxLoginService.wxLogin(code,phoneCode);
        return  result;
    }

    /**
     * 设置头像
     * @param file
     * @return
     */
    @PostMapping("/setavatar")
    @ApiOperation("设置头像")
    public SmileResult setavatar(MultipartFile  file){
        SmileResult result = clientWxLoginService.setClientAvatar(file);
        return  result;
    }

    /**
     * 设置个人信息
     * @param smileClient
     * @return
     */
    @PostMapping("/setinfo")
    @ApiOperation("设置个人信息")
    public SmileResult setinfo(@RequestBody SmileClient  smileClient){
        SmileResult result = clientWxLoginService.setInfo(smileClient);
        return  result;
    }

    /**
     * 获取个人信息
     * @param openId
     * @return
     */
    @GetMapping("/getinfo")
    @ApiOperation("获取个人信息")
    public SmileResult getinfo(@RequestParam("openId") String openId){
        SmileResult result = clientWxLoginService.getInfoByOpenId(openId);
        return  result;
    }
    @GetMapping("/check")
    @ApiOperation("签到")
    public SmileResult check(){
     return    checkService.check();
    }
    @GetMapping("/check/status")
    @ApiOperation("签到状态")
    public SmileResult checkStatus(){
        return    checkService.checkStatus();
    }
    @PostMapping ("/check/list")
    @ApiOperation("签到列表")
    public SmileResult checklist(@RequestBody CheckRecordSearchParamet searchParamet){
        return    checkService.getCheckRecordList(searchParamet);
    }

    @GetMapping ("/delivery/list")
    @ApiOperation("收货地址列表")
    public SmileResult deliveryListByNo(@RequestParam("clientNo") String clientNO){
        return    clientWxLoginService.getclientDeliveryListByClientNo(clientNO);
    }

    @PostMapping ("/delivery/add")
    @ApiOperation("收货地址添加")
    public SmileResult addDelivery(@RequestBody SmileClientDelivery smileClientDelivery){
        return    clientWxLoginService.addClientDelivery(smileClientDelivery);
    }

    @PostMapping ("/delivery/upd")
    @ApiOperation("收货地址修改")
    public SmileResult updDelivery(@RequestBody SmileClientDelivery smileClientDelivery){
        return    clientWxLoginService.updClientDelivery(smileClientDelivery);
    }




}
